# 检查selenium+浏览器驱动是否安装成功

# 写法1：
"""
from selenium import webdriver
driver = webdriver.Chrome()

driver.get("http://www.baidu.com")

# 退出
driver.quit()
"""
# 写法2：
import time

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

# r是py的写法，表示不转义
# driver = webdriver.Chrome(service=Service(r"E:\Python\chromedriver.exe"))
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("http://www.baidu.com")

driver.find_element(By.ID,'kw').send_keys('aaa')

driver.find_element(By.ID,'su').click()
print('driver:',driver)
time.sleep(2)
print(driver.find_element(By.XPATH, '//*[@id="1"]/div/div/h3/a').text)
print(driver.find_element(By.XPATH, '//*[@id="1"]/div/section/div[2]/div[1]/div/section[1]/div/div[1]/a[1]/img'))
input()

# 退出
driver.quit()
